<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="任务名称" prop="taskName">
        <el-input
          v-model="queryParams.taskName"
          placeholder="请输入任务名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="任务周数" prop="taskWeek">
        <el-input
          v-model="queryParams.taskWeek"
          placeholder="请输入任务周时间"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="完成状态" prop="taskType">
        <el-select
          v-model="queryParams.taskType"
          placeholder="完成状态"
          clearable
          size="small"
          style="width: 240px"
        >
          <el-option
            v-for="dict in statusOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['fuw:task:add']"
        >安排</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['fuw:task:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['fuw:task:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          :loading="exportLoading"
          @click="handleExport"
          v-hasPermi="['fuw:task:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="taskList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="任务编号" align="center" prop="taskId" :show-overflow-tooltip='true'/>
      <el-table-column label="任务名称" align="center" prop="taskName" :show-overflow-tooltip='true'/>
      <el-table-column label="规定开始时间" align="center" prop="taskStartTime" width="170">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.taskStartTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="规定完成时间" align="center" prop="taskEndTime" width="170">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.taskEndTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="任务周时间" align="center" prop="taskWeek" width="100"/>
      <el-table-column label="完成状态" align="center" prop="taskType" />
      <el-table-column label="任务权重" align="center" prop="taskNum" />
      <el-table-column label="实际完成时间" align="center" prop="taskOutTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.taskOutTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="医务人员" align="center" prop="medicalId" />
      <el-table-column label="组别编号" align="center" prop="workId" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['fuw:task:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['fuw:task:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改任务分配对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">

        <el-calendar>
          <!-- 这里使用的是 2.5 slot 语法，对于新项目请使用 2.6 slot 语法-->
          <template
            slot="dateCell"
            slot-scope="{date, data}">
            <div :class="data.isSelected ? 'is-selected' : ''" @click="drawerCale(data)" style="width:100%;height:100%">
              {{ data.day.split('-').slice(2).join('-') }} {{ data.isSelected ? '✔️' : ''}}
              <div v-for="item in scheduleData" :key="item" style="width:100%;margin-top:10px;">
                <el-tag :type="item.color" v-if="(item.workingDay).indexOf(data.day.split('-').join('-'))!=-1">
                  {{item.content}}
                </el-tag>
              </div>
            </div >
          </template>
        </el-calendar>

        <el-drawer
          :title="newData"
          :visible.sync="drawer"
          :append-to-body="true">
          <span>
            <div class="block" style="margin-right:30px;">
              <el-timeline>

                <el-timeline-item
                  v-for="(activity, index) in activities"
                  :timestamp="activity.timestamp"
                  :color="activity.color"
                  placement="top">
                  <el-card v-if="activity.type" style="position: relative;">
                    <div>
                      <h4>{{activity.taskId}}</h4>
                      <el-switch
                        style="float: right"
                        v-model="activity.type"
                        @click="editActivity(index)"
                        active-color="#13ce66"
                        inactive-color="#ff4949">
                      </el-switch>
                    </div>
                    <p>{{activity.taskName}}</p>
                    <h5>规定完成时间: {{activity.taskStartTime}} ~ {{activity.taskEndTime}}</h5>
                    <h5 v-if="activity.taskOutTime != ''">实际完成时间: {{activity.taskOutTime}}</h5>
                     <h5 v-if="activity.taskNum != ''">任务权重: {{activity.taskNum}}</h5>
                    <h5 v-if="activity.medicalId != ''">完成人员: {{activity.medicalId}}</h5>
                    <h5 v-if="activity.workId != ''">完成分组: {{activity.workId}}</h5>
                    <div>
                       <div style="top:180px;right:30px;position:absolute;transform: rotate(-30deg);" v-if="activity.taskType == '0'">
                         <h2 style="color:red;" v-if="activity.taskOutTime ? activity.taskOutTime : current_date > activity.taskEndTime">已逾期</h2>
                         <h2 style="color:dodgerblue;" v-else>进行中</h2>
                       </div>
                       <div style="top:180px;right:30px;position:absolute;transform: rotate(-30deg);" v-else>
                         <h2 style="color:green;">已提交</h2>
                       </div>
                    </div>
                  </el-card>
                  <el-card v-else>
                    <el-form :model="activity" label-width="80px" style="margin-top: 20px;">
                      <el-form-item label="任务描述">
                        <el-col :span="22">
                          <el-input type="textarea"
                                  placeholder="请输入内容"
                                  v-model="activity.taskName"
                                  maxlength="100"
                                  :autosize="{ minRows: 5}"
                                  show-word-limit />
                          </el-col>
                      </el-form-item>

                      <el-form-item label="规定时间">
                       <el-col :span="10">
                          <el-input placeholder="开始时间" prefix-icon="el-icon-time" v-model="activity.taskStartTime" readonly />
                        </el-col>
                        <el-col class="line" :span="2" style="text-align: center">-</el-col>
                        <el-col :span="10">
                          <el-input placeholder="结束时间" prefix-icon="el-icon-time" v-model="activity.taskEndTime" readonly />
                        </el-col>
                      </el-form-item>

                      <el-form-item label="任务权重">
                        <el-input-number v-model="activity.taskNum" :min="1" :max="10" ></el-input-number>
                      </el-form-item>

                      <el-form-item label="医务人员">
                        <el-select
                          v-model="activity.medicalId"
                          placeholder="请选择医务人员"
                          style="width: 90%"
                          :disabled="activity.medicalSelect"
                          @change="activity.workSelect = true">
                          <el-option
                            v-for="item in medicalList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                          </el-option>
                        </el-select>
                      </el-form-item>

                      <el-form-item label="岗位/组别">
                        <el-select
                          v-model="activity.workId"
                          placeholder="请选择岗位/组别"
                          style="width: 90%"
                          :disabled="activity.workSelect"
                          @change="activity.medicalSelect = true">
                          <el-option
                            v-for="item in postList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                          </el-option>
                        </el-select>
                      </el-form-item>

                    </el-form>
                  </el-card>
                </el-timeline-item>

              </el-timeline>
            </div>
            <div slot="footer" class="dialog-footer" style="margin-left: 50%; margin-bottom: 30px;">
              <el-button type="primary" @click="submitForm">提 交</el-button>
            </div>
          </span>
        </el-drawer>

      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { listTask,  listMedical, listPost, getTask, delTask, addTask, updateTask, exportTask } from "@/api/fuw/task";
import { listTasksDay } from "@/api/fuw/tasks";

export default {
  name: "Task",
  data() {
    return {
      // 下拉框禁用属性
      disabled1 : false,
      disabled2 : false,
      // 日历标签内容
      scheduleData: [
        {
          workingDay: "2021-11-02",
          content: "土方开挖",
          color: "warning"
        },
        {
          workingDay: "2021-11-03",
          content: "地基验坑",
          color: "primary"
        },
      ],
      // 抽屉
      drawer: false,
      newData: null,
      // 每日任务
      activities: [
        {
          taskId: '', // 任务编号
          taskName: '', // 任务描述
          taskStartTime: '9:00:00', // 任务规定开始时间
          taskEndTime: '12:00:00', // 任务规定完成时间
          taskType: '', // 任务完成状态（0：任务创建；1：任务进行中；2：任务逾期；3：任务完成）
          taskNum: 1, // 任务权重
          color: '', // 任务完成状态颜色
          taskWeek: '', // 日历时间
          taskOutTime: '', // 任务实际完成时间
          medicalId: '', // 完成人员
          workId: '', // 完成组员
          // 下拉框禁用
          medicalSelect: false,
          workSelect: false,
          type: false // 是否可以修改
        },
        {
          taskId: '', // 任务编号
          taskName: '', // 任务描述
          taskStartTime: '14:30:00', // 任务规定开始时间
          taskEndTime: '16:00:00', // 任务规定完成时间
          taskType: '', // 任务完成状态（0：任务创建；1：任务进行中；2：任务逾期；3：任务完成）
          taskNum: 1, // 任务权重
          color: '', // 任务完成状态颜色
          taskWeek: '', // 日历时间
          taskOutTime: '', // 任务实际完成时间
          medicalId: '', // 完成人员
          workId: '', // 完成组员
          // 下拉框禁用
          medicalSelect: false,
          workSelect: false,
          type: false // 是否可以修改
        },
        {
          taskId: '', // 任务编号
          taskName: '', // 任务描述
          taskStartTime: '16:00:00', // 任务规定开始时间
          taskEndTime: '17:30:00', // 任务规定完成时间
          taskType: '', // 任务完成状态（0：任务创建；1：任务进行中；2：任务逾期；3：任务完成）
          taskNum: 1, // 任务权重
          color: '', // 任务完成状态颜色
          taskWeek: '', // 日历时间
          taskOutTime: '', // 任务实际完成时间
          medicalId: '', // 完成人员
          workId: '', // 完成组员
          // 下拉框禁用
          medicalSelect: false,
          workSelect: false,
          type: false // 是否可以修改
        },
        {
          taskId: '', // 任务编号
          taskName: '', // 任务描述
          taskStartTime: '19:30:00', // 任务规定开始时间
          taskEndTime: '21:30:00', // 任务规定完成时间
          taskType: '', // 任务完成状态（0：任务创建；1：任务进行中；2：任务逾期；3：任务完成）
          taskNum: 1, // 任务权重
          color: '', // 任务完成状态颜色
          taskWeek: '', // 日历时间
          taskOutTime: '', // 任务实际完成时间
          medicalId: '', // 完成人员
          workId: '', // 完成组员
          // 下拉框禁用
          medicalSelect: false,
          workSelect: false,
          type: false // 是否可以修改
        }
      ],
      // 根据week查询对应的数据
      weekParams: {
        taskWeek: null
      },
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 任务分配表格数据
      taskList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 任务状态数据字典
      statusOptions: [],
      // 下拉框的2个数组
      medicalList: [],
      postList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        taskName: null,
        taskStartTime: null,
        taskEndTime: null,
        taskWeek: null,
        taskType: null,
        taskNum: null,
        taskOutTime: null,
        medicalId: null,
        workId: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  computed: {
    // 获取当前时间的计算函数
    current_date() {
      let date = new Date();
      let y = date.getFullYear();
      let MM = date.getMonth() + 1;
      MM = MM < 10 ? ('0' + MM) : MM;
      let d = date.getDate();
      d = d < 10 ? ('0' + d) : d;
      let h = date.getHours();
      h = h < 10 ? ('0' + h) : h;
      let m = date.getMinutes();
      m = m < 10 ? ('0' + m) : m;
      let s = date.getSeconds();
      s = s < 10 ? ('0' + s) : s;
      return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s;
    }
  },
  created() {
    this.getList();
    this.getDicts("fuw_task_type").then(response => {
      this.statusOptions = response.data;
    });
    // 查询下拉框数据
    this.getListByTabId();
  },
  methods: {
    /** 日期抽屉 */
    drawerCale(data){
      // 每日任务
      this.activities = [
        {
          taskId: '', // 任务编号
          taskName: '', // 任务描述
          taskStartTime: '9:00:00', // 任务规定开始时间
          taskEndTime: '12:00:00', // 任务规定完成时间
          taskType: '', // 任务完成状态（0：任务创建；1：任务进行中；2：任务逾期；3：任务完成）
          taskNum: 1, // 任务权重
          color: '', // 任务完成状态颜色
          taskWeek: '', // 日历时间
          taskOutTime: '', // 任务实际完成时间
          medicalId: '', // 完成人员
          workId: '', // 完成组员
          // 下拉框禁用
          medicalSelect: false,
          workSelect: false,
          type: false // 是否可以修改
        },
        {
          taskId: '', // 任务编号
          taskName: '', // 任务描述
          taskStartTime: '14:30:00', // 任务规定开始时间
          taskEndTime: '16:00:00', // 任务规定完成时间
          taskType: '', // 任务完成状态（0：任务创建；1：任务进行中；2：任务逾期；3：任务完成）
          taskNum: 1, // 任务权重
          color: '', // 任务完成状态颜色
          taskWeek: '', // 日历时间
          taskOutTime: '', // 任务实际完成时间
          medicalId: '', // 完成人员
          workId: '', // 完成组员
          // 下拉框禁用
          medicalSelect: false,
          workSelect: false,
          type: false // 是否可以修改
        },
        {
          taskId: '', // 任务编号
          taskName: '', // 任务描述
          taskStartTime: '16:00:00', // 任务规定开始时间
          taskEndTime: '17:30:00', // 任务规定完成时间
          taskType: '', // 任务完成状态（0：任务创建；1：任务进行中；2：任务逾期；3：任务完成）
          taskNum: 1, // 任务权重
          color: '', // 任务完成状态颜色
          taskWeek: '', // 日历时间
          taskOutTime: '', // 任务实际完成时间
          medicalId: '', // 完成人员
          workId: '', // 完成组员
          // 下拉框禁用
          medicalSelect: false,
          workSelect: false,
          type: false // 是否可以修改
        },
        {
          taskId: '', // 任务编号
          taskName: '', // 任务描述
          taskStartTime: '19:30:00', // 任务规定开始时间
          taskEndTime: '21:30:00', // 任务规定完成时间
          taskType: '', // 任务完成状态（0：任务创建；1：任务进行中；2：任务逾期；3：任务完成）
          taskNum: 1, // 任务权重
          color: '', // 任务完成状态颜色
          taskWeek: '', // 日历时间
          taskOutTime: '', // 任务实际完成时间
          medicalId: '', // 完成人员
          workId: '', // 完成组员
          // 下拉框禁用
          medicalSelect: false,
          workSelect: false,
          type: false // 是否可以修改
        }
      ];
      this.drawer = true;
      this.newData = data.day;
      this.weekParams.taskWeek = data.day;
      listTask(this.weekParams).then(response => {
        if(response.rows.length <= 4){
          for(let i=0; i<response.rows.length; i++){
            console.log(response.rows[i].taskStartTime.split(" ")[1])
            let timeNow = response.rows[i].taskStartTime.split(" ")[1];
            if(timeNow == "09:00:00"){
              this.activities[0].taskId = response.rows[i].taskId;
              this.activities[0].taskName = response.rows[i].taskName;
              this.activities[0].taskType = response.rows[i].taskType;
              this.activities[0].taskNum = response.rows[i].taskNum;
              this.activities[0].taskWeek = response.rows[i].taskWeek;
              this.activities[0].taskOutTime = response.rows[i].taskOutTime;
              this.activities[0].medicalId = response.rows[i].medicalId;
              this.activities[0].workId = response.rows[i].workId;
              this.activities[0].type = true;
              // 颜色赋值
              if(response.rows[i].taskType == '1'){
                this.activities[0].color = "#ffd306";
              }else if(response.rows[i].taskType == '2'){
                this.activities[0].color = "#ff0d0d";
              }else if(response.rows[i].taskType == '3'){
                this.activities[0].color = "#0bbd87";
              }else{
                this.activities[0].color = "";
              }
            }else if(timeNow == "14:30:00"){
              this.activities[1].taskId = response.rows[i].taskId;
              this.activities[1].taskName = response.rows[i].taskName;
              this.activities[1].taskType = response.rows[i].taskType;
              this.activities[1].taskNum = response.rows[i].taskNum;
              this.activities[1].taskWeek = response.rows[i].taskWeek;
              this.activities[1].taskOutTime = response.rows[i].taskOutTime;
              this.activities[1].medicalId = response.rows[i].medicalId;
              this.activities[1].workId = response.rows[i].workId;
              this.activities[1].type = true;
              // 颜色赋值
              if(response.rows[i].taskType == '1'){
                this.activities[1].color = "#ffd306";
              }else if(response.rows[i].taskType == '2'){
                this.activities[1].color = "#ff0d0d";
              }else if(response.rows[i].taskType == '3'){
                this.activities[1].color = "#0bbd87";
              }else{
                this.activities[1].color = "";
              }
            }else if(timeNow == "16:00:00"){
              this.activities[2].taskId = response.rows[i].taskId;
              this.activities[2].taskName = response.rows[i].taskName;
              this.activities[2].taskType = response.rows[i].taskType;
              this.activities[2].taskNum = response.rows[i].taskNum;
              this.activities[2].taskWeek = response.rows[i].taskWeek;
              this.activities[2].taskOutTime = response.rows[i].taskOutTime;
              this.activities[2].medicalId = response.rows[i].medicalId;
              this.activities[2].workId = response.rows[i].workId;
              this.activities[2].type = true;
              // 颜色赋值
              if(response.rows[i].taskType == '1'){
                this.activities[2].color = "#ffd206";
              }else if(response.rows[i].taskType == '2'){
                this.activities[2].color = "#ff0d0d";
              }else if(response.rows[i].taskType == '3'){
                this.activities[2].color = "#0bbd87";
              }else{
                this.activities[2].color = "";
              }
            }else if(timeNow == "19:30:00"){
              this.activities[3].taskId = response.rows[i].taskId;
              this.activities[3].taskName = response.rows[i].taskName;
              this.activities[3].taskType = response.rows[i].taskType;
              this.activities[3].taskNum = response.rows[i].taskNum;
              this.activities[3].taskWeek = response.rows[i].taskWeek;
              this.activities[3].taskOutTime = response.rows[i].taskOutTime;
              this.activities[3].medicalId = response.rows[i].medicalId;
              this.activities[3].workId = response.rows[i].workId;
              this.activities[3].type = true;
              // 颜色赋值
              if(response.rows[i].taskType == '1'){
                this.activities[3].color = "#ffd306";
              }else if(response.rows[i].taskType == '2'){
                this.activities[3].color = "#ff0d0d";
              }else if(response.rows[i].taskType == '3'){
                this.activities[3].color = "#0bbd87";
              }else{
                this.activities[3].color = "";
              }
            }
          }
        }
        this.loading = false;
      });
    },
    /** 修改显示状态 */
    editActivity(index) {
      this.activities[index].type = !this.activities[index].type;
    },
    /** 查询下拉框列表 */
    getListByTabId() {
      listMedical().then(response => {
        this.medicalList = response.data;
      });
      listPost().then(response => {
        this.postList = response.data;
      });
    },
    /** 查询任务分配列表 */
    getList() {
      this.loading = true;
      listTask(this.queryParams).then(response => {
        this.taskList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        taskId: null,
        taskName: null,
        taskStartTime: null,
        taskEndTime: null,
        taskWeek: null,
        taskType: null,
        taskNum: null,
        taskOutTime: null,
        medicalId: null,
        workId: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.taskId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 日历按钮操作 */
    handleAdd() {
      // 到tasks表中查询数据，然后进行标签赋予 ...
      listTasksDay().then(response => {
        console.log(response.data);
        this.scheduleData = response.data;
      });
      this.reset();
      this.open = true;
      this.title = "添加任务分配";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const taskId = row.taskId || this.ids
      getTask(taskId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改任务分配";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.activities.forEach((item, index) => {
        let formData = new FormData();
        formData.append("taskId", item.taskId);
        formData.append("taskName", item.taskName);
        formData.append("taskStartTime", this.newData + ' ' + item.taskStartTime);
        formData.append("taskEndTime", this.newData + ' ' + item.taskEndTime);
        formData.append("taskType", item.taskType);
        formData.append("taskNum", item.taskNum);
        formData.append("taskWeek", this.newData);
        formData.append("taskOutTime", this.newData + ' ' + item.taskOutTime);
        formData.append("medicalId", item.medicalId);
        formData.append("workId", item.workId);

        if (item.taskId != null && item.taskId != '') {
          updateTask(formData).then(response => {
            this.msgSuccess("修改成功");
            this.open = false;
            // 关闭抽屉
            this.drawer= false;
            this.getList();
          });
        } else {
          if((item.taskName != null && item.taskName != '')
            && (item.medicalId != '' || item.workId != '')){
            addTask(formData).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              // 关闭抽屉
              this.drawer= false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const taskIds = row.taskId || this.ids;
      this.$confirm('是否确认删除任务分配编号为"' + taskIds + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delTask(taskIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有任务分配数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.exportLoading = true;
          return exportTask(queryParams);
        }).then(response => {
          this.download(response.msg);
          this.exportLoading = false;
        }).catch(() => {});
    }
  }
};
</script>
